using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace Is
{
    public sealed class Has<TTarget> : IsBase<Is<TTarget>, TTarget>
    {
        internal Has(TTarget target, bool negate) : base(target, negate) { }


        public bool Existing(Expression<Func<TTarget, object>> predicate)
        {
            return ((IIs<TTarget>)this).Apply(
                t => Core.Is.HasExisting(t, predicate),
                t => !Core.Is.HasExisting(t, predicate));
        }

        public bool ExistingWithValue(Expression<Func<TTarget, TTarget>> predicate, TTarget expectedValue)
        {
            return ((IIs<TTarget>)this).Apply(
                t => Core.Is.HasExistingWithValue<TTarget>(t, predicate, expectedValue),
                t => !Core.Is.HasExistingWithValue<TTarget>(t, predicate, expectedValue));
        }

        public bool ExistingWithValue<TK>(Expression<Func<TTarget, TK>> predicate, TK expectedValue)
        {
            return ((IIs<TTarget>)this).Apply(
                t => Core.Is.HasExistingWithValue(t, predicate, expectedValue),
                t => !Core.Is.HasExistingWithValue(t, predicate, expectedValue));
        }

        public bool ExistingWithValue<TK>(Expression<Func<TTarget, TK>> predicate, TK expectedValue, IEqualityComparer<TK> comparer)
        {
            return ((IIs<TTarget>)this).Apply(
                t => Core.Is.HasExistingWithValue(t, predicate, expectedValue, comparer),
                t => !Core.Is.HasExistingWithValue(t, predicate, expectedValue, comparer));
        }
    }
}